#include "DefaultState.hpp"
#include "DialogState.hpp"
#include "../Notification.hpp"
#include "../Util.hpp"
#include "../Template.hpp"
#include <TweenEngine/Tween.h>
#include <cpp3ds/System/I18n.hpp>
#include <cpp3ds/Window/Window.hpp>
#include <cpp3ds/System/FileSystem.hpp>
#include <cpp3ds/System/Sleep.hpp>
#include <cpp3ds/Network/Socket.hpp>

namespace Template {

DefaultState *g_defaultState = nullptr;

DefaultState::DefaultState(StateStack& stack, Context& context, StateCallback callback)
: State(stack, context, callback)
{
	// State constructor, initialize everything here
	g_defaultState = this;



	#ifndef NDEBUG
	m_bannerImage.loadFromFile("images/dbanner.png");
	#else
	m_bannerImage.loadFromFile("images/banner.png");
	#endif
	m_bannerSprite.setTexture(m_bannerImage, true);
	m_bannerSprite.setPosition(200.f, 120.f);
	m_bannerSprite.setOrigin(m_bannerSprite.getGlobalBounds().width / 2, m_bannerSprite.getLocalBounds().height / 2);

	m_unbanBtn.setFillColor(cpp3ds::Color(120, 120, 120));
	m_unbanBtn.setOutlineColor(cpp3ds::Color(158, 158, 158));
	m_unbanBtn.setOutlineThickness(1.5);
	m_unbanBtn.setPosition(20.f, 35.f);
	#ifndef NDEBUG
	m_unbanBtn.setSize(cpp3ds::Vector2f(115.f, 30.f));
	#else
	m_unbanBtn.setSize(cpp3ds::Vector2f(275.f, 30.f));
	#endif

	m_textUnban.setFillColor(cpp3ds::Color::White);
	m_textUnban.setString("Unban");
	m_textUnban.setCharacterSize(14);
	m_textUnban.setPosition(m_unbanBtn.getPosition().x + (m_unbanBtn.getLocalBounds().width / 2), m_unbanBtn.getPosition().y + (m_unbanBtn.getLocalBounds().height / 2.13));
	m_textUnban.useSystemFont();
	m_textUnban.setOrigin(m_textUnban.getLocalBounds().width / 2, m_textUnban.getLocalBounds().height / 2);

	m_banBtn.setFillColor(cpp3ds::Color(120, 120, 120));
	m_banBtn.setOutlineColor(cpp3ds::Color(158, 158, 158));
	m_banBtn.setOutlineThickness(1.5);
	m_banBtn.setPosition(180.f, 35.f);
	m_banBtn.setSize(cpp3ds::Vector2f(115.f, 30.f));

	m_textBan.setFillColor(cpp3ds::Color::White);
	m_textBan.setString("Ban");
	m_textBan.setCharacterSize(14);
	m_textBan.setPosition(m_banBtn.getPosition().x + (m_banBtn.getLocalBounds().width / 2), m_banBtn.getPosition().y + (m_banBtn.getLocalBounds().height / 2.13 ));
	m_textBan.useSystemFont();
	m_textBan.setOrigin(m_textBan.getLocalBounds().width / 2, m_textBan.getLocalBounds().height / 2);

	m_backupBtn.setFillColor(cpp3ds::Color(120, 120, 120));
	m_backupBtn.setOutlineColor(cpp3ds::Color(158, 158, 158));
	m_backupBtn.setOutlineThickness(1.5);
	m_backupBtn.setPosition(20.f, 95.f);
	m_backupBtn.setSize(cpp3ds::Vector2f(115.f, 30.f));

	m_textBackup.setFillColor(cpp3ds::Color::White);
	m_textBackup.setString("Backup");
	m_textBackup.setCharacterSize(14);
	m_textBackup.setPosition(m_backupBtn.getPosition().x + (m_backupBtn.getLocalBounds().width / 2), m_backupBtn.getPosition().y + (m_backupBtn.getLocalBounds().height / 2.13));
	m_textBackup.useSystemFont();
	m_textBackup.setOrigin(m_textBackup.getLocalBounds().width / 2, m_textBackup.getLocalBounds().height / 2);

	m_restoreBtn.setFillColor(cpp3ds::Color(120, 120, 120));
	m_restoreBtn.setOutlineColor(cpp3ds::Color(158, 158, 158));
	m_restoreBtn.setOutlineThickness(1.5);
	m_restoreBtn.setPosition(180.f, 95.f);
	m_restoreBtn.setSize(cpp3ds::Vector2f(115.f, 30.f));

	m_textRestore.setFillColor(cpp3ds::Color::White);
	m_textRestore.setString("Restore");
	m_textRestore.setCharacterSize(14);
	m_textRestore.setPosition(m_restoreBtn.getPosition().x + (m_restoreBtn.getLocalBounds().width /2), m_restoreBtn.getPosition().y + (m_restoreBtn.getLocalBounds().height / 2.13));
	m_textRestore.useSystemFont();
	m_textRestore.setOrigin(m_textRestore.getLocalBounds().width / 2, m_textBackup.getLocalBounds().height / 2);

	m_uploadBtn.setFillColor(cpp3ds::Color(120, 120, 120));
	m_uploadBtn.setOutlineColor(cpp3ds::Color(158, 158, 158));
	m_uploadBtn.setOutlineThickness(1.5);
	m_uploadBtn.setPosition(20.f, 155.f);
	m_uploadBtn.setSize(cpp3ds::Vector2f(115.f, 30.f));

	m_textUpload.setFillColor(cpp3ds::Color::White);
	m_textUpload.setString("Upload");
	m_textUpload.setCharacterSize(14);
	m_textUpload.setPosition(m_uploadBtn.getPosition().x + (m_uploadBtn.getLocalBounds().width /2), m_uploadBtn.getPosition().y + (m_uploadBtn.getLocalBounds().height / 2.13));
	m_textUpload.useSystemFont();
	m_textUpload.setOrigin(m_textUpload.getLocalBounds().width / 2, m_textUpload.getLocalBounds().height / 2);

	m_aboutBtn.setFillColor(cpp3ds::Color(120, 120, 120));
	m_aboutBtn.setOutlineColor(cpp3ds::Color(158, 158, 158));
	m_aboutBtn.setOutlineThickness(1.5);
	m_aboutBtn.setPosition(180.f, 155.f);
	m_aboutBtn.setSize(cpp3ds::Vector2f(115.f, 30.f));

	m_textAbout.setFillColor(cpp3ds::Color::White);
	m_textAbout.setString("About");
	m_textAbout.setCharacterSize(14);
	m_textAbout.setPosition(m_aboutBtn.getPosition().x + (m_aboutBtn.getLocalBounds().width /2), m_aboutBtn.getPosition().y + (m_aboutBtn.getLocalBounds().height / 2.13));
	m_textAbout.useSystemFont();
	m_textAbout.setOrigin(m_textAbout.getLocalBounds().width / 2, m_textAbout.getLocalBounds().height / 2);

	#ifndef EMULATION
	u8 *LFCSBuffer = (u8*)malloc(sizeof(u8) * 0x110);
	if (R_SUCCEEDED(fsReadFile(LFCSBuffer, "/rw/sys/LocalFriendCodeSeed_B", 0x110, ARCHIVE_NAND_CTR_FS))) {
		m_info.setFillColor(cpp3ds::Color::White);
		m_info.setString("Found LocalFriendCodeSeed_B");
		m_info.setCharacterSize(12);
		m_info.setPosition(10.f, 210.f);
		m_info.useSystemFont();
	} else if (R_SUCCEEDED(fsReadFile(LFCSBuffer, "/rw/sys/LocalFriendCodeSeed_A", 0x110, ARCHIVE_NAND_CTR_FS))) {
		m_info.setFillColor(cpp3ds::Color::White);
		m_info.setString("Found LocalFriendCodeSeed_A");
	} else {
		m_info.setFillColor(cpp3ds::Color::Red);
		m_info.setString("No LFCS found.");
		m_info.setCharacterSize(12);
		m_info.setPosition(10.f, 210.f);
		m_info.useSystemFont();
	}
	#else
	m_info.setFillColor(cpp3ds::Color::Red);
	m_info.setString("No LFCS found.");
	m_info.setCharacterSize(12);
	m_info.setPosition(10.f, 210.f);
	m_info.useSystemFont();
	#endif

	#ifndef EMULATION
	#ifndef NDEBUG
	m_footage.setFillColor(cpp3ds::Color::White);
	m_footage.setString("Development Footage");
	m_footage.setCharacterSize(12);
	m_footage.setPosition(10.f, 170.f);
	m_footage.useSystemFont();
	#endif
	#endif
	#ifndef NDEBUG
	#ifdef EMULATION
	m_footage.setFillColor(cpp3ds::Color::White);
	m_footage.setString("Emulator Footage");
	m_footage.setCharacterSize(12);
	m_footage.setPosition(10.f, 170.f);
	m_footage.useSystemFont();
	#endif
	#endif

	#ifndef NDEBUG
	m_connect.setFillColor(cpp3ds::Color::White);
	m_connect.setString("Connected: ");
	m_connect.setCharacterSize(12);
	m_connect.setPosition(10.f, 190.f);
	m_connect.useSystemFont();

	#ifndef NDEBUG
	m_connectStatus.setCharacterSize(12);
	m_connectStatus.setPosition(80.f, 190.f);
	m_connectStatus.useSystemFont();
	#endif

}
#endif

DefaultState::~DefaultState()
{

}

int buffToInteger(char * buffer)
{
		int a = static_cast<int>(static_cast<unsigned char>(buffer[0]) << 24 |
				static_cast<unsigned char>(buffer[1]) << 16 |
				static_cast<unsigned char>(buffer[2]) << 8 |
				static_cast<unsigned char>(buffer[3]));
			return a;
}

int unbanFunc(void) {
		char buff[4]={0x0, 0x0, 0x3e, static_cast<char>(0xe3)};
		int a=buffToInteger(buff);

		std::cout<<std::hex<<a<<std::endl;
}

/*signed short ByteToShort(byte* bytes)
{
		signed short result = 0;
		result = (result<<8) + bytes[1];
		result = (result<<8) + bytes[0];
}

signed short ShortToByte(signed short num, byte* bytes)
{
		bytes[1] = num & 0xFF00;
		bytes[0] = num & 0x00FF;
}*/

void DefaultState::renderTopScreen(cpp3ds::Window& window)
{
	window.draw(m_bannerSprite);
	window.draw(m_footage);
	#ifndef NDEBUG
	window.draw(m_info);
	window.draw(m_connect);
	window.draw(m_connectStatus);
	#endif
}

void DefaultState::renderBottomScreen(cpp3ds::Window& window)
{
	window.draw(m_unbanBtn);
	window.draw(m_textUnban);
	#ifndef NDEBUG
	window.draw(m_banBtn);
	window.draw(m_textBan);
	#endif
	window.draw(m_backupBtn);
	window.draw(m_textBackup);
	window.draw(m_restoreBtn);
	window.draw(m_textRestore);
	window.draw(m_uploadBtn);
	window.draw(m_textUpload);
	window.draw(m_aboutBtn);
	window.draw(m_textAbout);
}

bool DefaultState::update(float delta)
{
	// Always update the tween manager if you have one in your class
	m_tweenManager.update(delta);

	return true;
}

bool DefaultState::processEvent(const cpp3ds::Event& event)
{
	// In this section, you can a lot of event, let's see how this can be done

	// First of all, you have to check your event type
	if (event.type == cpp3ds::Event::KeyPressed) {
		// Here, we can handle an event when a key is pressed, you can do a switch() to do an action according to the key pressed
		switch (event.key.code) {
			case cpp3ds::Keyboard::Start: {
				// Exit the app if the user pressed the Start button
				requestStackClear();
				return true;
			}
		}
	} else if (event.type == cpp3ds::Event::TouchBegan) {
		if (m_unbanBtn.getGlobalBounds().contains(event.touch.x, event.touch.y)) {
			TweenEngine::Tween::to(m_unbanBtn, util3ds::TweenText::FILL_COLOR_RGB, 0.1f)
				.target(212, 85, 85)
				.start(m_tweenManager);
			TweenEngine::Tween::to(m_unbanBtn, util3ds::TweenText::OUTLINE_COLOR_RGB, 0.1f)
				.target(222, 138, 138)
				.start(m_tweenManager);
			cpp3ds::TcpSocket socket;
			Notification::spawn("Connecting...");
			socket.connect("24.145.35.163", 22122);
			Notification::spawn("Sending Message to Host...");
			std::string message = "Hi, I'm UnbanMii";
			socket.send(message.c_str(), message.size() + 1);
			// Receive Answer from Host
			//char buffer[16];
			//Notification::spawn("Waiting for Host Answer...");
			//std::size_t received = 0;
			//socket.receive(buffer, sizeof(buffer), received);
			//std::cout << std::hex << "The Server Answered: " << buffer << std::endl;
			struct packet
			{



			};
}

		if (m_banBtn.getGlobalBounds().contains(event.touch.x, event.touch.y)) {
			#ifndef EMULATION
			#ifndef NDEBUG
			TweenEngine::Tween::to(m_banBtn, util3ds::TweenText::FILL_COLOR_RGB, 0.1f)
				.target(212, 85, 85)
				.start(m_tweenManager);
			TweenEngine::Tween::to(m_banBtn, util3ds::TweenText::OUTLINE_COLOR_RGB, 0.1f)
				.target(222, 138, 138)
				.start(m_tweenManager);
			requestStackPush(States::Dialog, false, [=](void *data) mutable {
				auto event = reinterpret_cast<DialogState::Event*>(data);
				if (event->type == DialogState::GetText)
				{
					u8 *LFCSBuffer = (u8*)malloc(sizeof(u8) * 0x110);
					if (R_SUCCEEDED(fsReadFile(LFCSBuffer, "/3ds/data/UnbanMii/dumps/LFCS_B", 0x110, ARCHIVE_SDMC))) {
								auto str = reinterpret_cast<cpp3ds::String*>(event->data);
								*str = _("Are you sure you want to ban yourself? \n\nIf so, make sure to have a Backup! \n\nBackup found: Yes");
								return true;
							} else if (R_SUCCEEDED(fsReadFile(LFCSBuffer, "/3ds/data/UnbanMii/dumps/LFCS_A", 0x110, ARCHIVE_SDMC))) {
								auto str = reinterpret_cast<cpp3ds::String*>(event->data);
								*str = _("Are you sure you want to ban yourself? \n\nIf so, make sure to have a Backup! \n\nBackup found: Yes");
								return true;
							} else {
								auto str = reinterpret_cast<cpp3ds::String*>(event->data);
								*str = _("Are you sure you want to ban yourself? \n\nIf so, make sure to have a Backup! \n\nBackup found: No");
								return true;
							}
				}
				else if (event->type == DialogState::GetTitle) {
								auto str = reinterpret_cast<cpp3ds::String *>(event->data);
								*str = _("Warning!");
								return true;
				}
				else if (event->type == DialogState::Response)
				{
								bool *accepted = reinterpret_cast<bool*>(event->data);
								if (*accepted)
								{
									u8 *LFCSBuffer = (u8*)malloc(sizeof(u8) * 0x110);
									if (R_SUCCEEDED(fsReadFile(LFCSBuffer, "/3ds/data/UnbanMii/dev/BanFunction/LFCS_B", 0x110, ARCHIVE_SDMC))) {
										fsWriteFile(LFCSBuffer, 0x110, "/rw/sys/LocalFriendCodeSeed_B", ARCHIVE_NAND_CTR_FS);
										g_requestReboot= true;
									}
									TweenEngine::Tween::to(m_banBtn, util3ds::TweenText::FILL_COLOR_RGB, 0.25f)
										.target(120, 120, 120)
										.start(m_tweenManager);
									TweenEngine::Tween::to(m_banBtn, util3ds::TweenText::OUTLINE_COLOR_RGB, 0.25)
										.target(158, 158, 158)
										.start(m_tweenManager);
									} else {
										TweenEngine::Tween::to(m_banBtn, util3ds::TweenText::FILL_COLOR_RGB, 0.25f)
											.target(120, 120, 120)
											.start(m_tweenManager);
										TweenEngine::Tween::to(m_banBtn, util3ds::TweenText::OUTLINE_COLOR_RGB, 0.25)
											.target(158, 158, 158)
											.start(m_tweenManager);
								}
								return true;
				}
				return false;
		});
	#else
	TweenEngine::Tween::to(m_banBtn, util3ds::TweenText::FILL_COLOR_RGB, 0.1f)
		.target(212, 85, 85)
		.start(m_tweenManager);
		TweenEngine::Tween::to(m_banBtn, util3ds::TweenText::OUTLINE_COLOR_RGB, 0.1f)
		.target(222, 138, 138)
		.start(m_tweenManager);
	#endif
	#else
	TweenEngine::Tween::to(m_banBtn, util3ds::TweenText::FILL_COLOR_RGB, 0.1f)
		.target(212, 85, 85)
		.start(m_tweenManager);
		TweenEngine::Tween::to(m_banBtn, util3ds::TweenText::OUTLINE_COLOR_RGB, 0.1f)
		.target(222, 138, 138)
		.start(m_tweenManager);
		Notification::spawn(_("Function not available to the Emulator."));
	#endif
}


		if (m_backupBtn.getGlobalBounds().contains(event.touch.x, event.touch.y)) {
			TweenEngine::Tween::to(m_backupBtn, util3ds::TweenText::FILL_COLOR_RGB, 0.1f)
				.target(212, 85, 85)
				.start(m_tweenManager);
			TweenEngine::Tween::to(m_backupBtn, util3ds::TweenText::OUTLINE_COLOR_RGB, 0.1f)
				.target(222, 138, 138)
				.start(m_tweenManager);
			#ifndef EMULATION
			u8 *LFCSBuffer = (u8*)malloc(sizeof(u8) * 0x110);
			if (R_SUCCEEDED(fsReadFile(LFCSBuffer, "/rw/sys/LocalFriendCodeSeed_B", 0x110, ARCHIVE_NAND_CTR_FS))) {
				fsWriteFile(LFCSBuffer, 0x110, "/3ds/data/UnbanMii/dumps/LFCS_B", ARCHIVE_SDMC);
				Notification::spawn(_("LFCS_B found, \nBackup Succeeded!"));
			} else if (R_SUCCEEDED(fsReadFile(LFCSBuffer, "/rw/sys/LocalFriendCodeSeed_A", 0x110, ARCHIVE_NAND_CTR_FS))) {
				fsWriteFile(LFCSBuffer, 0x110, "/3ds/data/UnbanMii/dumps/LFCS_A", ARCHIVE_SDMC);
				Notification::spawn(_("LFCS_A found, \nBackup Succeeded!"));
			}
		#else
		Notification::spawn(_("Function not available to the Emulator."));
		#endif
	}

		if (m_restoreBtn.getGlobalBounds().contains(event.touch.x, event.touch.y)) {
			TweenEngine::Tween::to(m_restoreBtn, util3ds::TweenText::FILL_COLOR_RGB, 0.1f)
				.target(212, 85, 85)
				.start(m_tweenManager);
			TweenEngine::Tween::to(m_restoreBtn, util3ds::TweenText::OUTLINE_COLOR_RGB, 0.1f)
				.target(222, 138, 138)
				.start(m_tweenManager);
			requestStackPush(States::Dialog, false, [=](void *data) mutable {
				auto event = reinterpret_cast<DialogState::Event*>(data);
				if (event->type == DialogState::GetText)
				{
								auto str = reinterpret_cast<cpp3ds::String*>(event->data);
								*str = _("Do you really want to restore your \nLocalFriendCodeSeed ? \n\n\nThe System will reboot after restoring!");
								return true;
				}
				else if (event->type == DialogState::GetTitle) {
								auto str = reinterpret_cast<cpp3ds::String *>(event->data);
								*str = _("Warning!");
								return true;
				}
				else if (event->type == DialogState::Response)
				{
								bool *accepted = reinterpret_cast<bool*>(event->data);
								if (*accepted)
								{
									TweenEngine::Tween::to(m_restoreBtn, util3ds::TweenText::FILL_COLOR_RGB, 0.25f)
										.target(120, 120, 120)
										.start(m_tweenManager);
									TweenEngine::Tween::to(m_restoreBtn, util3ds::TweenText::OUTLINE_COLOR_RGB, 0.25)
										.target(158, 158, 158)
										.start(m_tweenManager);
									#ifndef EMULATION
													u8 *LFCSBuffer = (u8*)malloc(sizeof(u8) * 0x110);
													if (R_SUCCEEDED(fsReadFile(LFCSBuffer, "/3ds/data/UnbanMii/dumps/LFCS_B", 0x110, ARCHIVE_SDMC)))	{
														fsWriteFile(LFCSBuffer, 0x110, "/rw/sys/LocalFriendCodeSeed_B", ARCHIVE_NAND_CTR_FS);
														cpp3ds::sleep(cpp3ds::milliseconds(1200));
														g_requestReboot = true;
													} else if (R_SUCCEEDED(fsReadFile(LFCSBuffer, "/3ds/data/UnbanMii/dumps/LFCS_A", 0x110, ARCHIVE_SDMC)))	{
														fsWriteFile(LFCSBuffer, 0x110, "/rw/sys/LocalFriendCodeSeed_A", ARCHIVE_NAND_CTR_FS);
														cpp3ds::sleep(cpp3ds::milliseconds(1200));
														g_requestReboot = true;
													}
													#else
													Notification::spawn("Function not available to the Emulator.");
													#endif
												} else {
												TweenEngine::Tween::to(m_restoreBtn, util3ds::TweenText::FILL_COLOR_RGB, 0.25f)
													.target(120, 120, 120)
													.start(m_tweenManager);
												TweenEngine::Tween::to(m_restoreBtn, util3ds::TweenText::OUTLINE_COLOR_RGB, 0.25)
													.target(158, 158, 158)
													.start(m_tweenManager);
								}
								return true;
				}
				return false;
		});
}

		if (m_uploadBtn.getGlobalBounds().contains(event.touch.x, event.touch.y)) {
			TweenEngine::Tween::to(m_uploadBtn, util3ds::TweenText::FILL_COLOR_RGB, 0.1f)
				.target(212, 85, 85)
				.start(m_tweenManager);
			TweenEngine::Tween::to(m_uploadBtn, util3ds::TweenText::OUTLINE_COLOR_RGB, 0.1f)
				.target(222, 138, 138)
				.start(m_tweenManager);
		}

		if (m_aboutBtn.getGlobalBounds().contains(event.touch.x, event.touch.y)) {
			TweenEngine::Tween::to(m_aboutBtn, util3ds::TweenText::FILL_COLOR_RGB, 0.25f)
				.target(212, 85, 85)
				.start(m_tweenManager);
			TweenEngine::Tween::to(m_aboutBtn, util3ds::TweenText::OUTLINE_COLOR_RGB, 0.25)
				.target(222, 138, 138)
				.start(m_tweenManager);
			requestStackPush(States::Dialog, false, [=](void *data) mutable {
					auto event = reinterpret_cast<DialogState::Event*>(data);
					if (event->type == DialogState::GetText)
					{
									#ifndef NDEBUG
									auto str = reinterpret_cast<cpp3ds::String*>(event->data);
									*str = _("This Software is made by Paul_GameDev\nand Kobayashi\n\nCreated using CPP3DS. \n\nVersion: v3.0 Debug");
									return true;
									#else
									auto str = reinterpret_cast<cpp3ds::String*>(event->data);
									*str = _("This Software is made by Paul_GameDev\nand Kobayashi\n\nCreated using CPP3DS. \n\nVersion: v3.0");
									return true;
									#endif
					}
					else if (event->type == DialogState::GetTitle) {
									auto str = reinterpret_cast<cpp3ds::String *>(event->data);
									*str = _("About UnbanMii");
									return true;
					}
					else if (event->type == DialogState::ShowCancelButton) {
						auto bol = reinterpret_cast<bool *>(event->data);
						*bol = false;
						return true;
					}
					else if (event->type == DialogState::Response)
					{
									bool *accepted = reinterpret_cast<bool*>(event->data);
									if (*accepted)
									{
													TweenEngine::Tween::to(m_aboutBtn, util3ds::TweenText::FILL_COLOR_RGB, 0.25f)
														.target(120, 120, 120)
														.start(m_tweenManager);
													TweenEngine::Tween::to(m_aboutBtn, util3ds::TweenText::OUTLINE_COLOR_RGB, 0.25)
														.target(158, 158, 158)
														.start(m_tweenManager);
									} else {
													TweenEngine::Tween::to(m_aboutBtn, util3ds::TweenText::FILL_COLOR_RGB, 0.25f)
														.target(120, 120, 120)
														.start(m_tweenManager);
													TweenEngine::Tween::to(m_aboutBtn, util3ds::TweenText::OUTLINE_COLOR_RGB, 0.25)
														.target(158, 158, 158)
														.start(m_tweenManager);
									}
									return true;
					}
					return false;
			});
		}

	} else if (event.type == cpp3ds::Event::TouchEnded)	{
		TweenEngine::Tween::to(m_unbanBtn, util3ds::TweenText::FILL_COLOR_RGB, 0.25f)
			.target(120, 120, 120)
			.start(m_tweenManager);
		TweenEngine::Tween::to(m_unbanBtn, util3ds::TweenText::OUTLINE_COLOR_RGB, 0.25f)
			.target(158, 158, 158)
			.start(m_tweenManager);
		TweenEngine::Tween::to(m_banBtn, util3ds::TweenText::FILL_COLOR_RGB, 0.25f)
			.target(120, 120, 120)
			.start(m_tweenManager);
		TweenEngine::Tween::to(m_banBtn, util3ds::TweenText::OUTLINE_COLOR_RGB, 0.25f)
			.target(158, 158, 158)
			.start(m_tweenManager);
		TweenEngine::Tween::to(m_backupBtn, util3ds::TweenText::FILL_COLOR_RGB, 0.25f)
			.target(120, 120, 120)
			.start(m_tweenManager);
		TweenEngine::Tween::to(m_backupBtn, util3ds::TweenText::OUTLINE_COLOR_RGB, 0.25f)
			.target(158, 158, 158)
			.start(m_tweenManager);
		TweenEngine::Tween::to(m_restoreBtn, util3ds::TweenText::FILL_COLOR_RGB, 0.25f)
			.target(120, 120, 120)
			.start(m_tweenManager);
		TweenEngine::Tween::to(m_restoreBtn, util3ds::TweenText::OUTLINE_COLOR_RGB, 0.25f)
			.target(158, 158, 158)
			.start(m_tweenManager);
		TweenEngine::Tween::to(m_uploadBtn, util3ds::TweenText::FILL_COLOR_RGB, 0.25f)
			.target(120, 120, 120)
			.start(m_tweenManager);
		TweenEngine::Tween::to(m_uploadBtn, util3ds::TweenText::OUTLINE_COLOR_RGB, 0.25f)
			.target(158, 158, 158)
			.start(m_tweenManager);
	}

	return true;
}

} // namespace Template
